package servicempl;

import java.util.List;

import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import dao.PaperMapper;
import pojo.Paper;
import service.Paperservice;
import untils.Page;
@Service
public class Paperservicempl implements Paperservice {
	@Resource
	private PaperMapper papermapper;

	public PaperMapper getPapermapper() {
		return papermapper;
	}

	public void setPapermapper(PaperMapper papermapper) {
		this.papermapper = papermapper;
	}

	@Override
	public Paper find(int ID) {
		Paper p = papermapper.find(ID);
		return p;
	}

	@Override
	public Page<Paper> findpaperList(int page, int rows, String name, String studentname, String paperclass) {
		// 创建论文对象
       Paper paper = new Paper();
		// 判断论文名称
		if(name!=null){
			paper.setName(name);
		}
		// 判断论文作者
		if(studentname!=null){
			paper.setStudentname(studentname);
		}
		// 判断论文类型
		if(paperclass!=null){
			paper.setPaperclass(paperclass);
		}
		paper.setStart((page-1) * rows) ;
		// 每页数
		paper.setRows(rows);
		// 查询客户列表
		List<Paper> papers = papermapper.findpaperList(paper);
		// 查询客户列表总记录数
		Integer count = papermapper.papercount(paper);
		// 创建Page返回对象
		Page<Paper> result = new Page<>();
		result.setPage(page);
		result.setRows(papers);
		result.setSize(rows);
		result.setTotal(count);
		return result;
	}
	//输入论文信息
	public void increase(Paper paper) {
		papermapper.increase(paper);
	}

}
